<?php
	if($_SESSION['kboy_user'] == "" && $_SESSION['kboy_phone'] == "" || $_SESSION['kboy_userid'] == ""){
		if(empty($_COOKIE['username'])||empty($_COOKIE['password'])){//如果session为空，并且用户没有选择记录登录状
		echo "<script language=\"javascript\">location.href=\"login.php\";</script>";
		exit;
		}else{
			$user_email = $_COOKIE['username'];
			$user_password = $_COOKIE['password'];
			$is_reguser = getNewsNums("kboy_user"," ( user_email='$user_email' or user_phone='$user_email' )  AND user_password='$user_password'");
			if($is_reguser >0){
				$_SESSION['kboy_user'] = $user_email;

				$_SESSION['kboy_userid'] = getClassName("kboy_user","uid","( user_email='$user_email' or user_phone='$user_email' )");

				$_SESSION['kboy_leader'] = getClassName("kboy_user","user_leader","( user_email='$user_email' or user_phone='$user_email' )");
				
				mysql_query("update kboy_user set user_lasttime='$THIS_TODAY_DATETIME',user_lastip='".getip()."' where ( user_email='$user_email' or user_phone='$user_email' )");
				echo "<script language=\"javascript\">location.href=\"/user_index.php\";</script>";
				exit;
			}else{
				echo "<script language=\"javascript\">location.href=\"login.php\";</script>";
				
				exit;
			}
		}
	}
?>
